# -*- coding: utf-8 -*-
# !/usr/bin/env python3
# Author: eddyhhu(胡皓)
import logging
import uvicorn
from app import create_app
from configs import config
from common.log import config_log
from tortoise.contrib.fastapi import register_tortoise

# init log
config_log(filename=config.FILE_PATH, level=logging.DEBUG)
LOG = logging.getLogger()

# init app
app = create_app(**config.app_config)
register_tortoise(
    app,
    config=config.TORTOISE_DB_CONFIG,
    modules={"models": ["dao.models"]},
    generate_schemas=True,
    add_exception_handlers=True,
)

if __name__ == "__main__":
    uvicorn.run(app='main:app', host=config.SERVER_CONFIG["host"], port=config.SERVER_CONFIG["port"],
                reload=config.SERVER_CONFIG["reload"])
